import java.math.RoundingMode;
import java.text.ChoiceFormat;
import java.text.NumberFormat;
import java.util.Scanner;
import java.util.Stack;

public class Calc {
    static Stack<Character> operateStack = new Stack<>();
    static Stack<Double> numberStack = new Stack<>();
    static String str;
    static int judge=0;

    public static void main(String[] args) {
        operateStack.push('=');
        try {
            read();
            if(judge==0) {
                System.out.print(str);
                System.out.printf("%.2f", numberStack.pop());
            }
            if(judge==1){
                System.out.print("NaN");
            }
        } catch (Exception e) {
            System.err.print("Wrong Format");
        }
    }

    public static void read() throws IllegalAccessException, IllegalArgumentException {
        int decide = 0, i = 0;
        double temp, data_1, data_2, num_ex;
        Scanner scanner = new Scanner(System.in);
        str = scanner.nextLine();
        str=str+"=";
        char ope_top, ptr_prev;
        for (int index = 0; index < str.length(); index++) {
            char c = str.charAt(index);
            if(c==' ')  continue;
            if(index<str.length()-1&&str.charAt(index+1)>'0'&&str.charAt(index+1)<='9'&&((c=='-'&&index==0)||(c=='-'&&str.charAt(index-1)=='('))) {
                index++;
                c=str.charAt(index);
                ptr_prev = c;
                index++;
                if (str.charAt(index) > '9' || str.charAt(index) < '0') {
                    num_ex = 0-(ptr_prev - '0');
                    temp = num_ex;
                } else {
                    for (num_ex = 0-(ptr_prev - '0'); ; index++) {
                        if (str.charAt(index) <= '9' && str.charAt(index) >= '0') {
                            num_ex = num_ex * 10 - (str.charAt(index) - '0');
                        } else {
                            break;
                        }
                    }
                    temp = num_ex;
                }
                numberStack.push(temp);
                index--;
                continue;
            }
            if (c >= '0' && c <= '9') {
                ptr_prev = c;
                index++;
                if (str.charAt(index) > '9' || str.charAt(index) < '0') {
                    num_ex=ptr_prev-'0';
                    temp = num_ex;
                } else {
                    if(ptr_prev=='0'){
                        throw new IllegalAccessException();
                    }
                    for (num_ex = ptr_prev - '0'; ; index++) {
                        if (str.charAt(index) <= '9' && str.charAt(index) >= '0') {
                            num_ex = num_ex * 10 + str.charAt(index) - '0';
                        } else {
                            break;
                        }
                    }
                    temp = num_ex;
                }
                numberStack.push(temp);
                index--;
            } else if(c=='+'||c=='-'||c=='*'||c=='/'||c=='('||c==')'||c=='='){
                while (true)//做死循环一直比较直到优先级大于
                {
                    decide = compare(operateStack.peek(), str.charAt(index));
                    if (decide <= 0 || str.charAt(index) == '=') {
                        ope_top = operateStack.pop();
                        if (ope_top == '=') {
                            if (str.charAt(index) != '=') {
                                operateStack.push('=');
                                operateStack.push(str.charAt(index));
                            }
                            break;
                        } else if (ope_top == '+' || ope_top == '-' || ope_top == '*' || ope_top == '/')//如果是双目运算符
                        {
                            data_2 = numberStack.pop();
                            data_1 = numberStack.pop();
                            temp = operate(data_1, data_2, ope_top);
                            numberStack.push(temp);
                        }else if(ope_top=='('&&str.charAt(index)==')')  break;
                    } else {
                        operateStack.push(str.charAt(index));
                        break;
                    }
                }
            }else{
                throw new IllegalAccessException();
            }
        }
    }

    private static int compare(char top, char read) {
        char tempChar;
        int i, prio_top = 0, prio_read = 0, temp_int = 0;
        for (i = 1; i >= 0; i--) {
            if (i == 1)
                tempChar = top;
            else
                tempChar = read;
            switch (tempChar) {
                case ')':
                    temp_int = 0;
                    break;
                case '=':
                    temp_int = 0;
                    break;
                case '+':
                    temp_int = 1;
                    break;
                case '-':
                    temp_int = 1;
                    break;
                case '*':
                    temp_int = 2;
                    break;
                case '/':
                    temp_int = 2;
                    break;
                case '(': {
                    if (i == 1)
                        temp_int = 0;
                    else
                        temp_int = 6;
                }
                break;
            }
            if (i == 1)
                prio_top = temp_int;
            else
                prio_read = temp_int;
        }
        return Integer.compare(prio_read, prio_top);
    }

    public static double operate(double data_1, double data_2, char operate) throws IllegalAccessException {
        switch (operate) {
            case '+':
                return data_1 + data_2;
            case '-':
                return data_1 - data_2;
            case '*':
                return data_1 * data_2;
            case '/':
                if (data_2 == 0) {
                    judge=1;
                    return 9999999;
                }
                return data_1 / data_2;
            default:
                throw new IllegalAccessException();
        }
    }
}
